<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>判断时间段</title>
    <script>
        function greetUser() {
            var time = document.getElementById("time").value;
            var hour = parseInt(time);
        
            var greetingMessage;
            if (hour >= 6 && hour < 12) {
                greetingMessage = "早上好！";
            } else if (hour >= 12 && hour < 18) {
                greetingMessage = "下午好！";
            } else if (hour >= 18 && hour < 23) {
                greetingMessage = "晚上好！";
            } else if (hour >= 0 && hour < 5) {
                greetingMessage = "这是休息时间，不要说话";
            } else {
                alert("请输入有效的时间（0-23）");
                return;
            }
        
            alert(greetingMessage);
        }
        </script>
        </head>
        <body>
        <label for="time">请输入当前时间</label>
        <input type="text" id="time">
        <button onclick="greetUser()">确定</button>
        </body>
        </html>